package com.bwie.servicemodule.base;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.Toast;

import com.bwie.servicemodule.controler.OkGoControler;

public abstract class BaseListActivity extends BaseActivity implements  OkGoControler.HttpListener{

    private OkGoControler controler;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        controler = new OkGoControler();
        controler.setListener(this);
        initData();
        setAdapter();
        setListener();
    }

    /**初始化数据方法*/
    protected abstract void initData();

    /**设置适配器方法*/
    protected abstract void setAdapter();

    /**设置监听器*/
    protected abstract void setListener();

    //显示loaddialog
    protected void showDialog(){}
    //关闭loaddialog
    protected void disDialog(){}

    //显示toast方法
    protected void showToast(String msg){
        Toast.makeText(this,msg,Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onSuccess(String url, String result) {
        disDialog();
    }

    @Override
    public void onSuccess(String url, String result, int type) {
        disDialog();
    }

    @Override
    public void onErro(String url, String msg) {
        disDialog();
    }
}
